/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import accesodatos.Costos;

/**
 *
 * @author Ana Maria
 */
public class CostosGUI extends javax.swing.JInternalFrame {

    boolean porMes;
    boolean porAño;
    boolean porEstrato;
    boolean porOcupacion;
    boolean porGrupoEtareo;
    String mes;
    String anio;

    public CostosGUI() {
        initComponents();

        comboAño.setEnabled(false);
        comboMes.setEnabled(false);

        grupoTipo.add(rb_barra);
        grupoTipo.add(rb_pastel);

        grupoDemografia.add(rb_estrato);
        grupoDemografia.add(rb_ocupacion);
        grupoDemografia.add(rb_grupoE);

        this.pack();
        this.setVisible(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoDemografia = new javax.swing.ButtonGroup();
        grupoTipo = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        comboAño = new javax.swing.JComboBox();
        comboMes = new javax.swing.JComboBox();
        checkAño = new javax.swing.JCheckBox();
        checkMes = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        rb_estrato = new javax.swing.JRadioButton();
        rb_ocupacion = new javax.swing.JRadioButton();
        rb_grupoE = new javax.swing.JRadioButton();
        jPanel3 = new javax.swing.JPanel();
        rb_pastel = new javax.swing.JRadioButton();
        rb_barra = new javax.swing.JRadioButton();
        butt_consultar = new javax.swing.JButton();
        butt_salir = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("Tw Cen MT", 1, 24)); // NOI18N
        jLabel1.setText("Costos prestacion de servicios a pacientes");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Fecha"));

        comboAño.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2006", "2007", "2008", "Todos" }));

        comboMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
        comboMes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboMesActionPerformed(evt);
            }
        });

        checkAño.setText("Por Año");
        checkAño.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkAñoActionPerformed(evt);
            }
        });

        checkMes.setText("Por Mes");
        checkMes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkMesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(checkAño)
                    .addComponent(checkMes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(comboAño, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(comboMes, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(62, 62, 62))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboAño, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkAño))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkMes))
                .addGap(0, 14, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Demografia"));

        rb_estrato.setText("Por Estrato");

        rb_ocupacion.setText("Por Ocupacion");

        rb_grupoE.setText("Por Grupo Etareo");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rb_estrato)
                    .addComponent(rb_ocupacion)
                    .addComponent(rb_grupoE))
                .addContainerGap(118, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rb_estrato)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rb_ocupacion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rb_grupoE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo Grafica"));

        rb_pastel.setText("Pastel");

        rb_barra.setText("Barra");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rb_pastel)
                    .addComponent(rb_barra))
                .addContainerGap(60, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rb_pastel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(rb_barra)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        butt_consultar.setText("Consultar");
        butt_consultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butt_consultarActionPerformed(evt);
            }
        });

        butt_salir.setText("Salir");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(7, 7, 7)
                                .addComponent(butt_consultar)
                                .addGap(26, 26, 26)
                                .addComponent(butt_salir, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel1)
                .addGap(60, 60, 60)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(butt_consultar)
                            .addComponent(butt_salir))))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void comboMesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboMesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboMesActionPerformed

    private void checkAñoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkAñoActionPerformed

        if (checkAño.isSelected()) {

            comboAño.setEnabled(true);
            this.repaint();


        } else {

            comboAño.setEnabled(false);
            this.repaint();

        }


    }//GEN-LAST:event_checkAñoActionPerformed

    private void checkMesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkMesActionPerformed


        if (checkMes.isSelected()) {

            comboMes.setEnabled(true);
            this.repaint();

        } else {

            comboMes.setEnabled(false);
            this.repaint();

        }

    }//GEN-LAST:event_checkMesActionPerformed

    private void butt_consultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butt_consultarActionPerformed

        porMes = checkMes.isSelected();
        porAño = checkAño.isSelected();
        porEstrato = rb_estrato.isSelected();
        porOcupacion = rb_ocupacion.isSelected();
        porGrupoEtareo = rb_grupoE.isSelected();
        mes = comboMes.getSelectedItem().toString();
        anio = comboAño.getSelectedItem().toString();

        boolean tipoP = rb_pastel.isSelected();
        boolean tipoB = rb_barra.isSelected();
        Costos c = new Costos();

        String consulta = c.construirConsultaCosto(porMes, porAño, porEstrato, porOcupacion, porGrupoEtareo, mes, anio);
        if (tipoP) {


            c.CrearGraficoDePastel(consulta, "Colombia Saludable - Resultados Consulta");

        } else if (tipoB) {

            c.CrearGraficoDeBarras(consulta, "Colombia Saludable - Resultados Consulta", "", "");
        } else {

            c.CrearGraficoDeBarras(consulta, "Colombia Saludable - Resultados Consulta", "", "");


        }





    }//GEN-LAST:event_butt_consultarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton butt_consultar;
    private javax.swing.JButton butt_salir;
    private javax.swing.JCheckBox checkAño;
    private javax.swing.JCheckBox checkMes;
    private javax.swing.JComboBox comboAño;
    private javax.swing.JComboBox comboMes;
    private javax.swing.ButtonGroup grupoDemografia;
    private javax.swing.ButtonGroup grupoTipo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JRadioButton rb_barra;
    private javax.swing.JRadioButton rb_estrato;
    private javax.swing.JRadioButton rb_grupoE;
    private javax.swing.JRadioButton rb_ocupacion;
    private javax.swing.JRadioButton rb_pastel;
    // End of variables declaration//GEN-END:variables

    public static void main(String Args[]) {

        CostosGUI cu = new CostosGUI();

    }
}
